package models;

import static siena.Model.all;
import java.util.List;
import play.data.validation.Required;
import siena.Query;

public class Notification extends BaseModel {
	
	public enum NotificationType {INBOX}
	
	@Required
	public User owner;
	@Required
	public String message;
	@Required
	public NotificationType type;
		
	public static Query<Notification> all() {
		return all(Notification.class);
	}
	
	public static Query<Notification> all(User owner) {
        return all().filter("owner", owner).order("-created_time");
	}
	
	public static Notification findById(Long id) {
		Notification notification = all().filter("id", id).get();
		return notification;
	}
	
	public static int count(User owner) {
		return all().filter("owner", owner).count();
	}
	
	public static List<Notification> paginate(Query<Notification> query, int offset, int limit) {
		return query.fetch(limit, offset);
	} 
	
}